#include <stdio.h>
#include <stdlib.h>

#define F_PRINT_ERR(e)\
do\
{\
    if(e == NULL)\
    {\
        printf("open error\n");\
        exit(-1);\
    }\
}\
while (0)

int main(int argc,char *argv[])
{
//    FILE *pfr=fopen("../04fputc/main.c","r");
    // 运行参数 1
    FILE *pfr=fopen(argv[1],"r");
    F_PRINT_ERR(pfr);

//    FILE *pfw=fopen("cpmain.c","w+");
    // 运行参数 2
    FILE *pfw=fopen(argv[2],"w+");
    F_PRINT_ERR(pfw);

    char ch;
    while ((ch = fgetc(pfr)) != EOF) {
        putchar(fputc(ch,pfw));
    }
    fclose(pfr);
    fclose(pfw);
    return 0;
}
